home *** CD-ROM | disk | FTP | other *** search
- /* KEYBOARD.C
- This file contains an assortment of Keyboard handling rutines. None
- of the rutines are ment to be executed independently- rather they
- are ment to be linked with and called from a program of your own.
- For more information on keyboard buffer handling in the IBM PC, please
- read the comments in the file STUFFKB3.ASM. For more programming examples
- in both C and ASM, please see STUFFKB3.ASM.
-
- Note: All examples below were writen for compilation with Turbo C ver. 2.01
- (By Borland International).
-
- The information contained may be considered Public Domain and may be used
- freely as long as the author is not held libiable for its soundness.
- */
-
- /*Note: The below examples assume that the keyboard buffer has been setup
- in the way that a IBM computer would by default. It has been left up to
- you to determin, if necessary, whether this default condition still exists.*/
-
-
- #include <dos.h>
-
- int anykeys(void); /*checks for presence of keystorkes in buffer. returns
- 1 if present, 0 if not. Not confused by <cntrl><brks>*/
- void clrkb(void); /*clears keyboard buffer by setting head=tail. */
-
-
-
- int anykeys(void)
- {
- /*return 0 if 0 keys in buffer, else return 1. Keyboard buffer not otherwise
- affected.*/
-
- int far *head;
- int far *tail;
-
- head= MK_FP(0x40,0x1A);
- tail= MK_FP(0x40,0x1C);
-
- if (*head==*tail)
- return(0);
- else
- return(1);
- }
-
-
- void clrkb(void)
- {
- /*quickly clears the keyboard buffer */
- int far *head;
- int far *tail;
-
- head= MK_FP(0x40,0x1A);
- tail= MK_FP(0x40,0x1C);
-
- *head=*tail;
- }
-
-